﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using InstantNaukriDAL;
using System.Collections.Generic;

public partial class JobseekerProfile_EditOtherInformation : System.Web.UI.Page
{
    int ProfileId = 0, UserId = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["UserId"] == null)
                Response.Redirect("Default.aspx");
            string roleid = "";
            clsUserLoginDAL objclsUserLoginDAL = new clsUserLoginDAL();
            if (Request.QueryString["roleid"] != null)
                roleid = clsEncryptionDecryption.Decrypt(Request.QueryString["roleid"].ToString());
            if (roleid == "4")
            {
                IN_TB_USER objIN_TB_USER = new IN_TB_USER();
                if (Session["UserId"] != null)
                    objIN_TB_USER = objclsUserLoginDAL.GetUserByID(Convert.ToInt32(Session["UserId"].ToString()));
                if (objIN_TB_USER != null)
                {
                    Session["UserId"] = objIN_TB_USER.ID;
                    dvAutority.Visible = true;
                    Fillddls();
                    FillOtherInfo(objIN_TB_USER.ID);
                }
            }
        }
    }

    protected void btnOtherinfo_Click(object sender, EventArgs e)
    {
        try
        {

            clsOtherDAL objclsOtherDAL = new clsOtherDAL();
            IN_TB_OTHER ibjIN_TB_OTHER = new IN_TB_OTHER();
            if (Session["UserId"] != null)
                ibjIN_TB_OTHER.USER_ID = Convert.ToInt32(Session["UserId"]);
            ibjIN_TB_OTHER.DESIRED_JOB_TYPE = Convert.ToInt32(ddlDJobType.SelectedValue);
            ibjIN_TB_OTHER.DESIRED_EMPOLOYMENT_TYPE = Convert.ToInt32(ddlDemploymentType.SelectedValue);
            ibjIN_TB_OTHER.WORK_PERMIT_LOCATION = Convert.ToInt32(ddlWorkPermitType.SelectedValue);
            ibjIN_TB_OTHER.HAVE_VISA = Convert.ToInt32(ddlHaveVisa.SelectedValue);
            ibjIN_TB_OTHER.VISA_TYPE = Convert.ToInt32(ddlVisaType.SelectedValue);
            ibjIN_TB_OTHER.CREATED_BY = ibjIN_TB_OTHER.USER_ID;
            ibjIN_TB_OTHER.CREATED_ON = DateTime.Now;
            ibjIN_TB_OTHER.MODIFIED_BY = ibjIN_TB_OTHER.USER_ID;
            ibjIN_TB_OTHER.MODIFIED_ON = DateTime.Now;
            int resumeid = objclsOtherDAL.SaveLOtherInfo(ibjIN_TB_OTHER);

            if (Request.QueryString["roleid"] != null && Session["UserId"] != null)
            {
                Response.Redirect("JobseekerPrieview.aspx?roleid=" + Request.QueryString["roleid"].ToString());
            }
            else
            {
                Session["RoleId"] = null;
                Response.Redirect("JobSeekerLogin.aspx");
            }

        }
        catch (Exception)
        {

            throw;
        }

    }

    protected void FillOtherInfo(int UserId)
    {
        try
        {
            clsOtherDAL objclsOtherDAL = new clsOtherDAL();
            IN_TB_OTHER ibjIN_TB_OTHER = new IN_TB_OTHER();
            ibjIN_TB_OTHER = objclsOtherDAL.GetOtherinfoByUserId(UserId);
            if (ibjIN_TB_OTHER != null)
            {
                ddlDJobType.SelectedValue = Convert.ToString(ibjIN_TB_OTHER.DESIRED_JOB_TYPE);
                ddlDemploymentType.SelectedValue = Convert.ToString(ibjIN_TB_OTHER.DESIRED_EMPOLOYMENT_TYPE);
                ddlWorkPermitType.SelectedValue = Convert.ToString(ibjIN_TB_OTHER.WORK_PERMIT_LOCATION);
                ddlHaveVisa.SelectedValue = Convert.ToString(ibjIN_TB_OTHER.HAVE_VISA);
                ddlVisaType.SelectedValue = Convert.ToString(ibjIN_TB_OTHER.VISA_TYPE);
            }
        }
        catch (Exception)
        {

            throw;
        }
    }



    private void Fillddls()
    {
        try
        {
            // Have Visa
            ddlHaveVisa.Items.Clear();
            ddlHaveVisa.AppendDataBoundItems = true;
            ddlHaveVisa.Items.Add("Select");
            ddlHaveVisa.Items[0].Value = "-1";
            ddlHaveVisa.Items.Add("No");
            ddlHaveVisa.Items[1].Value = "0";
            ddlHaveVisa.Items.Add("Yes");
            ddlHaveVisa.Items[2].Value = "1";

            // Job Type
            clsJobTypeDAL objclsJobTypeDAL = new clsJobTypeDAL();
            List<IN_TB_JOB_TYPE> objIN_TB_JOB_TYPE = new List<IN_TB_JOB_TYPE>();
            objIN_TB_JOB_TYPE = objclsJobTypeDAL.GetAllJobTypes();
            ddlDJobType.Items.Clear();
            ddlDJobType.AppendDataBoundItems = true;
            ddlDJobType.DataTextField = "JOB_TYPE";
            ddlDJobType.DataValueField = "ID";
            ddlDJobType.Items.Add("Select");
            ddlDJobType.Items[0].Value = "0";
            ddlDJobType.DataSource = objIN_TB_JOB_TYPE;
            ddlDJobType.DataBind();

            // Employment Type
            clsEmploymentTypeDAL objclsEmploymentTypeDAL = new clsEmploymentTypeDAL();
            List<IN_TB_EMPLOYMENT_TYPE> objIN_TB_EMPLOYMENT_TYPE = new List<IN_TB_EMPLOYMENT_TYPE>();
            objIN_TB_EMPLOYMENT_TYPE = objclsEmploymentTypeDAL.GetAllEmploymentTypes();
            ddlDemploymentType.Items.Clear();
            ddlDemploymentType.AppendDataBoundItems = true;
            ddlDemploymentType.DataTextField = "EMPLOYMENT_TYPE";
            ddlDemploymentType.DataValueField = "ID";
            ddlDemploymentType.Items.Add("Select");
            ddlDemploymentType.Items[0].Value = "0";
            ddlDemploymentType.DataSource = objIN_TB_EMPLOYMENT_TYPE;
            ddlDemploymentType.DataBind();

            // Visa Type
            clsVisaTypeDAL objclsVisaTypeDAL = new clsVisaTypeDAL();
            List<IN_TB_VISA_TYPE> objIN_TB_VISA_TYPE = new List<IN_TB_VISA_TYPE>();
            objIN_TB_VISA_TYPE = objclsVisaTypeDAL.GetAllEmploymentTypes();
            ddlVisaType.Items.Clear();
            ddlVisaType.AppendDataBoundItems = true;
            ddlVisaType.DataTextField = "VISA_TYPE";
            ddlVisaType.DataValueField = "ID";
            ddlVisaType.Items.Add("Select");
            ddlVisaType.Items[0].Value = "0";
            ddlVisaType.DataSource = objIN_TB_VISA_TYPE;
            ddlVisaType.DataBind();

            // Work Permit Type
            clsPermitTypeDAL objclsPermitTypeDAL = new clsPermitTypeDAL();
            List<IN_TB_WORK_PERMIT_TYPE> objIN_TB_WORK_PERMIT_TYPE = new List<IN_TB_WORK_PERMIT_TYPE>();
            objIN_TB_WORK_PERMIT_TYPE = objclsPermitTypeDAL.GetAllWorkPermitTypes();
            ddlWorkPermitType.Items.Clear();
            ddlWorkPermitType.AppendDataBoundItems = true;
            ddlWorkPermitType.DataTextField = "WORK_PERMIT_TYPE";
            ddlWorkPermitType.DataValueField = "ID";
            ddlWorkPermitType.Items.Add("Select");
            ddlWorkPermitType.Items[0].Value = "0";
            ddlWorkPermitType.DataSource = objIN_TB_WORK_PERMIT_TYPE;
            ddlWorkPermitType.DataBind();
        }
        catch (Exception ex)
        {
        }
    }
}
